<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<c:set var="BasePath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="Plugins"
	value="${pageContext.request.contextPath}/res/plugins"></c:set>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>获取销售订单数据</title>
<link href="${Plugins}/ligerUI/skins/Aqua/css/ligerui-all.css"
	rel="stylesheet" type="text/css" />
<link href="${Plugins}/ligerUI/skins/Gray/css/all.css" rel="stylesheet"
	type="text/css" />
<script src="${Plugins}/jquery/jquery-1.3.2.min.js"
	type="text/javascript"></script>
<script src="${Plugins}/ligerUI/js/ligerui.min.js"
	type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/jquery.validate.min.js"
	type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/jquery.metadata.js"
	type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/messages_cn.js"
	type="text/javascript"></script>
<script src="${BasePath}/res/js/common/jquery.form.js"
	type="text/javascript"></script>
<script type="text/javascript" src="${BasePath}/res/js/ligerCommon.js"></script>
<script src="${BasePath}/res/js/common/jquery.validate.method.js"
	type="text/javascript"></script>
<script src="${Plugins}/datepicker/WdatePicker.js"
	type="text/javascript"></script>
<style type="text/css">
body {
	font-size: 14px;
}

.l-table-edit {
	
}

.l-table-edit-td {
	padding: 4px;
}

.l-button-submit,.l-button-test {
	width: 80px;
	float: left;
	margin-left: 10px;
	padding-bottom: 2px;
}

.l-verify-tip {
	left: 230px;
	top: 120px;
}

.p-tab .s-lab {
	font-size: 14px;
	font-family: "微软雅黑", ​ "宋体", ​Arial, ​sans-serif;
}

input.l-textarea {
	width: 170px;
	height: 20px;
	font-size: 14px;
}

.navbar {
	height: 20px;
	border-bottom: #E6E6E6 solid 1px;
	line-height: 20px;
}
</style>
</head>
<body style="padding: 10px">
	<div class="navbar">
		<span>您当前的位置：</span> 商品管理 &gt; 商品库存数据同步
	</div>
	<form name="form1" method="post" action="synchroProdInventory.do"
		id="form1">
		<br>
		<table cellpadding="0" cellspacing="0" class="l-table-edit p-tab">
			<tr>
				<td align="right" class="l-table-edit-td s-lab"><font
					color="red">*</font>仓库名称：</td>
				<td align="left" class="l-table-edit-td s-lab">
				<select id="warehouseCode" name="warehouseCode" class="l-textarea" validate="{required:true}" title="请选择仓库">
						<option value="">请选择</option>
						<c:forEach items="${whareHouses }" var="wharehouse">
							<option value="${wharehouse.whNo }">${wharehouse.whName
								}</option>
						</c:forEach>
				</select></td>
			</tr>
			<tr>
				<td align="right" class="l-table-edit-td s-lab"><font
					color="red">*</font>开始时间：</td>
				<td align="left" class="l-table-edit-td s-lab"><input id="startDate" type="text" name="startDate" value="${startDate }" class="Wdate l-textarea" validate="{required:true}" 
    	onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH',readOnly:true,autoPickDate:true,maxDate:'#F{$dp.$D(\'endDate\')||\'2020-10-01\'}'})" >
				</td>
				<td align="left"></td>
			</tr>
			<tr>
				<td align="right" class="l-table-edit-td s-lab"><font
					color="red">*</font>结束时间：</td>
				<td align="left" class="l-table-edit-td s-lab"><input id="endDate" type="text" name="endDate" value="${endDate }" class="Wdate l-textarea" validate="{required:true}"
    	onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH',readOnly:true,autoPickDate:true,minDate:'#F{$dp.$D(\'startDate\')||\'2013-01-01\'}'})" >
				</td>
				<td align="left"></td>
			</tr>
		</table>



		<input type="submit" value="保存" id="Button1" class="l-button l-button-submit" />
		<input type="button" value="取消" name="tests" id="tests" class="l-button l-button-test" />
	</form>
	<div style="display: none">
		<!--  数据统计代码 -->
	</div>
	<script type="text/javascript">
		//$.ligerDialog.waitting('正在保存中,请稍候...'); setTimeout(function () { $.ligerDialog.closeWaitting(); }, 2000);
	</script>
	<script type="text/javascript">
		$(function() {
			$.validator.addMethod("afterStartDate", function(value, element) {
				var resultFlag = true;
				var starTime = $("#startDate").val();
				var endTime = value;
				if (starTime != "" && endTime <= starTime) {
					resultFlag = false;
				}
				return resultFlag;
			}, "结束时间要晚于开始时间");

			//validate
			$.metadata.setType("attr", "validate");
			var v = $("form").validate(
					{
						errorPlacement : function(lable, element) {
							lable.ligerHideTip();
							if (element.hasClass("l-textarea")) {
								element.ligerTip({
									content : lable.html(),
									target : element[0]
								});
							} else if (element.hasClass("l-text-field")) {
								element.parent().ligerTip({
									content : lable.html(),
									target : element[0]
								});
							} else {
								lable.appendTo(element.parents("td:first")
										.next("td"));
							}
						},
						success : function(lable) {
							lable.ligerHideTip();
							lable.remove();
						},
						submitHandler : function() {
							var startDate = $('#startDate').val().replace("-","/").replace("-","/")+ ":00:00";
				    		var endDate = $('#endDate').val().replace("-","/").replace("-","/")+ ":00:00";
				    		var intervalTime = new Date(endDate).getTime() - new Date(startDate).getTime();
				    		var twoDateTime = 2 * 60 * 60 * 1000;
				    		if ((intervalTime - twoDateTime) > 0) {
				    			$.ligerDialog.warn('同步时间只能相隔2小时');
				    			return false;
				    		}
							
							
							$("form .l-text,.l-textarea").ligerHideTip();
							var options = {
								type : 'POST',
								beforeSend : function() {
									$("#form1").find(":submit,:button").attr(
											"disabled", true);
									$.ligerDialog.waitting('正在同步中,请稍候...');
								},
								dataType : "json",
								success : function(data) {
									var msg = data.msg;
									var success = data.success;
									$.ligerDialog.closeWaitting();
									if (success) {
										//同步成功
										$.ligerDialog.alert(msg);
									} else {
										//同步失败
										$.ligerDialog.alert(msg);
									}
									$("#form1").find(":submit,:button")
											.removeAttr("disabled");

								},
								error : function() {
									$.ligerDialog.alert('请求异常');
								}
							}, $form1 = $("#form1");
							$form1.ajaxSubmit(options);
							return false;
						}
					});
		});
		// 取消
		$("#tests").click(function() {
			close_liger_tab();
		});
	</script>
</body>
</html>